# BigDFT.DoS module

This module is used to display the Density of States (DoS).

The Main Class of this module is `DoS`. Essentially, such class interpret the information coming from a set of energies and represents in this way a curve that smears such energies.

class DiracSuperposition(dos, wgts=[1.0])[source]

Sum of weighted Dirac deltas.

Defines a superposition of Dirac deltas which can be used to plot the density of states. Such deltas are given on a per k-point basis and can be also equipped with a array of weights, which may be useful to define Partial Density of States.

Parameters
• dos (matrix) – array containing the density of states per each k-point. Should be of shape 2, a list of energies per kpoint

• wgts (float, array, matrix) – contains the weights of each of the k-points. Could be a constant, in which case the same weight is applied everywhere, a list (on a k-point basis), or a matrix, where each energy have its own weight.

curve(xs, sigma, wgts=None)[source]

Output the quantities to be plotted.

Returns the x,y arrays that can be passed to plotting programs to represent the DoS.

Parameters
• xs (list) – xrange of the output.

• sigma (float) – smearing of the energies, as returned by `peaks()`.

• wgts (list) – array of further weights to be applied, if needed

Returns

x,y numpy arrays of the curve in the

specified range.

Return type

collections.NamedTuple

peak(omega, e, sigma)[source]

Define if a peak is a Gaussian or a Lorenzian (temporarily only the gaussian is defined)

peaks(xs, dos, norms, sigma)[source]

Return the array of the whole set of peaks

class DoS(bandarrays=None, energies=None, evals=None, logfiles_dict=None, units='eV', reference_fermi_level=None, label='1', sigma=0.2, fermi_level=None, norm=1.0, sdos=None, **kwargs)[source]

Density of states class.

Extract a quantity which is associated to the DoS, that can be plotted

Parameters
• bandarrays (list) – a list of `BandArray` class instances.

• energies (array-like) – a list of energies to be plotted. Useful for plotting a single DoS from an array.

• evals (dict) – dictionary of eigenvalues from a logfile yaml serialization. May be useful if a `Logfile` class is not available.

• logfiles_dict (dict) – dictionary of `Logfile` class instances as values to be employed to create the set of DoS. The keys of the dictionary are the labels of the corresponding curves.

• reference_fermi_level (float) – useful in the case of a logfiles_dict. the value of the reference fermi level is compared with the fermi level of all the logfiles in order to align all the curves. It is assumed that the fermi levels are properly defined in all the logfiles.

• units (str) – The units of the provided energies, and fermi_level. Should be AU of eV.

• label (str) – label of the curve.

• sigma (float) – smearing of the energies. Always provided in eV.

• fermi_level (float) – set the value of the fermi energy.

• norm (float, list) – weights of the `DiracSuperposition` instantation for each of the k-points.

• sdos – spatial density of states instantiation

• **kwargs – keyword arguments of the `set_range()` method.

append_from_bandarray(bandarrays, label)[source]

Add a new band array to the previous DoS.

This method can be called to include in the DoS the energies which come from another run.

Parameters
• bandarrays (BigDFT.BZ.BandArray) – a instance of the eigenvalues which come from a logfile. Can be retrieved by the BigDFT.Logfiles.Logfile.evals attribute of the class.

• label (str) – id of the run.

append_from_dict(evals, label)[source]

Get the energies from the different flavours given by the dict.

append(energies, label=None, units='eV', norm=1.0)[source]

Include other DoS inside the instance.

Parameters
• energies (list) – energies of the superpsition.

• label (str) – id of the DoS.

• units (str) – units of the energies. Can be AU or eV.

• norm (float, list) – weights of the density of states.

fermi_level(fermi_level, units='eV')[source]

Set the fermi level of the DoS.

Parameters
• fermi_level (float) – the value of the chemical potential.

• units (str) – the units of this value. can be AU or eV.

set_range(npts=None, e_min=None, e_max=None, deltae=None)[source]

Adjust the range of the curves to be plotted/represented.

This function can be called if it is necessary to adjust the range of the curves.

Parameters
• npts (int) – minimum number of points of the curves.

• deltae (float) – minimum resolution of the x range. Always in eV.

• e_min (float) – Minimum value of the energy. Always in eV.

• e_max (float) – Maximum value of the energy. Always in eV.

get_curves(range=None, sigma=None)[source]

Get the curves of the DoS instance, ready for plotting.

This function provides a dictionary of data for each of the curves which can be plots by the `plot()` method. They can be retrieved also to be plotted with other plotting tools.

Parameters
• range (array) – the xrange to be employed for the curves. If not provided, use the `range` attribute of the instance.

• sigma (float) – the smearing of the dos. If not provided, use the `sigma` attribute of the instance.

Returns

a dicitonary of a label: (x,y) items,

where x,y are the data to be plotted. (x,y) is a py:class:~collections.namedtuple class instance, as returned from DiracSuperposition.

Return type

collections.OrderedDict

shift_curves(shift)[source]

Shift the curves.

Apply a constant or a per-curve shift on the data.

Parameters

shift (float, list, dict) – the shift to be implemented. If it is a constant, it is performed on all the curves. If it is a list, the shif is performed on all the DoS, in appending order. Should have the same length of the labels. If is is a dict, it assumes the shift per label. Only the indicated DoS will be shifted. The units of the shift are always in eV.

dump(**kwargs)[source]

Represent the dta to be plotted as a table.

This is a commodity function that can be used to redirect the output of the DoS into a file.

Parameters

**kwargs – the arguments of the `get_curves()` method.

Returns

serialized DoS, gnuplot-friendly, can be written in a file.

Return type

(str)

plot(sigma=None, ax=None, smearing_slider=False)[source]

Commodity Function to plot the DoS.

Plot the curves which are available.

Parameters
• sigma (float) – smearing of the curves

• ax (matplotlib.pyplot.axis) – matplotlib axis instance. Created if not given.

• smearing_slider (bool) – If True, a slider is drawn to control the semaring manually. Useful when outside the jupyter inline visualization.

Returns

The axis instance used for the plot.

This is also present in the ax1 attribute of the class.

Return type

matplotlib.pyplot.axis